<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      所有代办事项长度： {{todoParams.length}}
      <br>
      未完成长度 {{todoParams.undone}}
      <br>
      未完成长度 {{todoParams.done}}
      <br>
      紧急的
      {{todoParams.urgent}}
      <br>
      未完成且紧急的
      {{todoParams.undoneAndUrgent}}
    </div>

    <script src="./vue.global.js"></script>
    <script>
      const { createApp } = Vue;
      const app = createApp({
        data() {
          return {
            todos: [
              {
                id: 1,
                content: "吃饭",
                urgent: true,
                done: true,
              },
              {
                id: 2,
                content: "睡觉",
                urgent: true,
                done: false,
              },
              {
                id: 3,
                content: "打豆豆",
                urgent: false,
                done: true,
              },
              {
                id: 4,
                content: "爬山",
                urgent: false,
                done: true,
              },
            ],
          };
        },
       
        computed: {
          todoParams(){
            const params = {
              length: this.todos.length,
              done: this.todos.filter(todo=> todo.done).length || 0,
              undone:this.todos.filter(todo=> !todo.done).length || 0,
              urgent: this.todos.filter(todo=> todo.urgent).length || 0,
              undoneAndUrgent: this.todos.filter(todo=> !todo.done).filter(todo=> todo.urgent).length ,
            }
            return params
          }
        },
      });

      app.mount("#app");
    </script>
  </body>
</html>
